# Makefile for gcc compiler for iPhone

TOOLCHAIN=/toolchain/usr/bin
PROJECTNAME=wallpaper
DYLIBNAME=$(PROJECTNAME).dylib

STRIP=$(TOOLCHAIN)/strip
CC=$(TOOLCHAIN)/arm-apple-darwin9-g++-4.2.1
LD=$(CC)
LDFLAGS =  -dynamiclib -arch arm -init _WPInitialize -g0 -Os -Wall
LDFLAGS += -lobjc -lsubstrate -lstdc++.6
LDFLAGS += -framework CoreFoundation 
LDFLAGS += -framework Foundation 
LDFLAGS += -framework UIKit 
LDFLAGS += -framework PhotoLibrary 
LDFLAGS += -framework Preferences 
LDFLAGS += -framework CoreGraphics
LDFLAGS += -L"/toolchain/sdk/usr/lib"
LDFLAGS += -L"/toolchain/3th_part/lib"
LDFLAGS += -F"/toolchain/sdk/System/Library/Frameworks"
LDFLAGS += -F"/toolchain/sdk/System/Library/PrivateFrameworks"


CFLAGS =  -g0 -Os -Wall
CFLAGS += -I"/toolchain/sdk/usr/include"
CFLAGS += -I"/toolchain/cocoa/include"
CFLAGS += -I"/toolchain/gcc4.2.1/include"

BUILDDIR=/Library/MobileSubstrate/DynamicLibraries
SRCDIR=.
OBJS=$(patsubst %.mm,%.o,$(wildcard $(SRCDIR)/*.mm))

all:	dist

$(DYLIBNAME):	$(OBJS)
	$(LD) $(LDFLAGS) -o $@ $^

%.o:	%.mm
	$(CC) -c $(CFLAGS) $< -o $@

dist:	$(DYLIBNAME)
	$(STRIP) -SXx $(DYLIBNAME)
#	@cp -r $(DYLIBNAME) ${PROJECTNAME}/$(DYLIBNAME)
	
clean:
	@rm -f $(SRCDIR)/*.o
	@rm -f $(SRCDIR)/$(DYLIBNAME)
